﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Configuration;

namespace WorkItemVisualization
{
    /// <summary>
    /// Interaction logic for Options.xaml
    /// </summary>
    public partial class Options : Window
    {
        public Options()
        {
            InitializeComponent();

            //Set settings
            string value = ConfigurationManager.AppSettings["UseMtmLinks"];
            bool bValue = bool.Parse(value);

            if (bValue)
                btnMTM.IsChecked = true;
            else
                btnTWA.IsChecked = true;
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            WriteSettings();
            this.Close();
        }

        private void WriteSettings()
        {
            ConfigurationManager.AppSettings.Set("UseMtmLinks", ProcessRadioButton(btnMTM).ToString());
        }

        /// <summary>
        /// Indicates whether or not the checkbox is checked
        /// </summary>
        /// <param name="box">The checkbox to process</param>
        /// <returns>True if it is checked or false if it is not</returns>
        private bool ProcessRadioButton(RadioButton btn)
        {
            if ((btn.IsChecked != null) && (btn.IsChecked == true))
                return true;
            else
                return false;
        }
    }
}